/**
 * TOPCODER SRM 516 Division II Level 2 (500 points)
 * http://community.topcoder.com/stat?c=problem_statement&pm=10846&rd=14541
 */

package topcoder;

import java.util.HashSet;
import java.util.Set;

public class NetworkXOneTimePad {

	public int crack(String[] ps, String[] cs){
		long[] pl = new long[ps.length];
		long[] cl = new long[cs.length];
		for(int i=0; i<ps.length; i++){
			pl[i] = Long.parseLong(ps[i],2);
			if(i<cs.length)
				cl[i] = Long.parseLong(cs[i], 2);
		}
		
		Set<Long> keys = new HashSet<Long>();
		for(long p : pl){
			for(long c : cl){
				long key = p ^ c;
				boolean valid = true;
				for(long c2 : cl){
					boolean contains = false;
					for(long p2 : pl){
						if((p2 ^ key) == c2){
							contains = true;
							break;
						}
					}
					if(!contains){
						valid = false;
						break;
					}
				}
				if(valid)
					keys.add(key);
			}
		}
		return keys.size();
	}
	
	public static void main(String[] args) {
		NetworkXOneTimePad t = new NetworkXOneTimePad();
		System.out.println(t.crack(new String[]{"01001010101100111011011", "01100010101010001010000", "10100110010011101011001", "10010100001000111001101", "00110101111011101011110", "10001001000001010110111", "00101100110101111100010", "00011001110011110010110", "11011000011101111000100", "01011010011001111111101", "11000100001111101111001", "11111001100001011010001", "01000011000000101101100", "01011000001000000000011", "11111010001000101001110", "01110011011111010000101", "11111000110001011101001", "11011001010000001111001", "01101010110010110110111", "01111011011010110001001", "11010011000000101110110", "00000100011001000100010", "01101101000011100110001", "01010001011001000101111"}, new String[] {"00111000101011111100000", "10001000001111101110101", "11011011010000100111000", "11101110010110101001100", "11110111011000111110000", "00000110101100111010111", "00010001100011111011000", "10111001111001100100111", "11000110111010010001100", "10011010101011010101101", "10101000010001100011001", "10000001100011111000010", "10011000111010101010011", "10010011111010010000001", "10101111100000110011111", "10100000001001011111110", "01010110101011101100011", "10110001111100000101011", "00111010010010001000111", "01001011100010000011001", "00011010111110101101010", "01100100110000111110111", "00111011000010001111111", "00011011110011011010111"}));
		
	}
}
